home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / demos / retinarave / include / mouse.s < prev    next >
Text File  |  1980-01-03  |  1KB  |  50 lines

  1.  
  2.  
  3. ReadMouse:
  4.     clr.w d0
  5.     move.b Joy0Dat+Custom,d0    joy0dat
  6.     move.w OldY,d1
  7.     sub d0,d1
  8.     move.w d1,YP        calculate diference between the
  9.                 ;last reading and the current reading
  10.  
  11.     move.w d0,OldY        store the current reading
  12.  
  13.     cmp.w #128,YP        is the diference greater that 128
  14.                 ;(129-255)
  15.     blt Mouse_Not_128
  16.     sub.w #256,YP        make it 0 to 127
  17.  
  18. Mouse_Not_128:
  19.     cmp.w #-128,YP        is the differnce between -128 and 0
  20.     bgt Mouse_Not_Minus
  21.     add.w #256,YP        make it in the range 0 to 127
  22.  
  23. Mouse_Not_Minus:
  24.     move.w YP,d0
  25.     add.w d0,YP2        add on the difference to the mouse
  26.                 ;position
  27.  
  28.     cmp.w #YMin,YP2        check if it goes out of range
  29.     bge.s YPos_Ok1
  30.     move.w #YMin,YP2    stop if going out of range
  31. YPos_Ok1:
  32.  
  33.     cmp.w #YMax,YP2        check if it goes out of range
  34.     blt.s YPos_Ok2
  35.     move.w #YMax,YP2    stop if going out of range
  36. YPos_Ok2:
  37.  
  38.     move.w #YMax,d0        invert the reading as mouse reader
  39.     sub.w YP2,d0        gives the reverse info
  40.     add.w #YMin,d0
  41.     move.w d0,YPos        store in user var
  42.  
  43.     rts
  44.  
  45. YPos:    dc.w 0
  46. OldY:    dc.w 0
  47. YP:    dc.w 0
  48. YP2:    dc.w YMax
  49. OldYP2:    dc.w Ymin
  50.